package model;

import java.util.Observable;
import java.util.Observer;

abstract class FunctionalUnit implements Observer{

	private Pipe destinationPipe;

	private Pipe sourcePipe;

	public FunctionalUnit(Pipe sourcePipe, Pipe destinationPipe) {
		this.sourcePipe = sourcePipe;
		this.destinationPipe = destinationPipe;
	}
	
	public int getPipeData(String field){
		return sourcePipe.getData(field);
	}
	
	public void setPipeData(String field, int data){
		destinationPipe.setData(field, data);
	}
	
	public abstract void execute1();
	
	public abstract void execute2();

	public void update(Observable o, Object arg) {
		if (arg instanceof String) {
			if ( ((String) arg) .equals("GET") )
				execute1();
			if ( ((String) arg) .equals("SET") )
				execute2();
		}		
	}

}